import csv

def read_coordinates_from_csv(file_path):
    # 初始化一个空列表用于存储坐标
    coordinates = []
    try:
        # 使用with语句打开文件，确保文件在使用后会被正确关闭
        with open(file_path, mode='r', newline='') as csvfile:
            # 使用csv模块的reader函数读取csv文件
            csvreader = csv.reader(csvfile)
            # 遍历csv文件中的每一行
            for row in csvreader:
                if len(row) == 3:  # Ensure it's a 3D coordinate
                    try:
                        x, y, z = map(float, row)
                        coordinates.append((x, y, z))
                    except ValueError:
                        print(f"Skipping invalid row: {row}")
                else:
                    print(f"Skipping invalid row: {row}")
    except FileNotFoundError:
        print(f"File not found: {file_path}")
    return coordinates

def get_coordinates(file_path):
    return read_coordinates_from_csv(file_path)

# Example usage
if __name__ == "__main__":
    file_path = "points.csv"  # Replace with your CSV file path
    coords = read_coordinates_from_csv(file_path)
    print("Read coordinates:", coords)